package com.ruoyi.project.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mapper.AssetsMapper;
import com.ruoyi.project.domain.Assets;
import com.ruoyi.project.service.IAssetsService;
import com.ruoyi.common.support.Convert;

/**
 * 资产管理 服务层实现
 * 
 * @author ruoyi
 * @date 2018-11-01
 */
@Service
public class AssetsServiceImpl implements IAssetsService 
{
	@Autowired
	private AssetsMapper assetsMapper;

	/**
     * 查询资产管理信息
     * 
     * @param assetsId 资产管理ID
     * @return 资产管理信息
     */
    @Override
	public Assets selectAssetsById(Long assetsId)
	{
	    return assetsMapper.selectAssetsById(assetsId);
	}
	
	/**
     * 查询资产管理列表
     * 
     * @param assets 资产管理信息
     * @return 资产管理集合
     */
	@Override
	public List<Assets> selectAssetsList(Assets assets)
	{
	    return assetsMapper.selectAssetsList(assets);
	}
	
    /**
     * 新增资产管理
     * 
     * @param assets 资产管理信息
     * @return 结果
     */
	@Override
	public int insertAssets(Assets assets)
	{
	    return assetsMapper.insertAssets(assets);
	}
	
	/**
     * 修改资产管理
     * 
     * @param assets 资产管理信息
     * @return 结果
     */
	@Override
	public int updateAssets(Assets assets)
	{
	    return assetsMapper.updateAssets(assets);
	}

	/**
     * 删除资产管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteAssetsByIds(String ids)
	{
		return assetsMapper.deleteAssetsByIds(Convert.toStrArray(ids));
	}

	/**
	 * 根据名字查询信息
	 * @param assetsName
	 * @return
	 */
	public Assets selectAssetsassetsName(String assetsName){
		Assets assets=new Assets();
		assets.setAssetsName(assetsName);
		List<Assets> list=assetsMapper.selectAssetsList(assets);
		if (list!=null){
			Assets assets1=list.get(0);
			return assets1;
		}else {
			return null;
		}
	}

	/**
	 * 根据部门id查询信息
	 * @param deptId
	 * @return
	 */
	@Override
	public List<Assets> selectAssetsdeptId (long deptId){
		Assets assets=new Assets();
		assets.setDeptId(deptId);
		return assetsMapper.selectAssetsList(assets);
	}

	/**
	 * 根据部门名称查询信息
	 * @param deptName
	 * @return
	 */
	@Override
	public List<Assets> selectAssetsdeptName(String deptName){
		Assets assets=new Assets();
		assets.setAssetsName(deptName);
		return assetsMapper.selectAssetsList(assets);
	}
	
}
